package HLLib.control;

import javax.microedition.lcdui.Image;

import HLCode.HLClass;
import HLCode.HLClassManager;
import HLCode.HLClassManager_H;
import HLCode.HLObject;
import HLLib.base.HLGraphics;
import HLLib.base.HLGraphics_H;
import HLLib.base.HLImage;
import HLLib.base.HLMathFP;
import HLLib.base.HLMathFP_H;
import HLLib.handfere.HLIOManager;

public class HLNetWait extends HLObject implements HLGraphics_H, HLMathFP_H {
    public HLClass GetClass(HLClassManager classManager) {
        return classManager.GetLibClass(HLClassManager_H.CLASS_GROUP_TYPE_LIB_CONTROL, HLClassManager_H.LIB_CLASS_CONTROL_NetWait);
    }

    private Image[] imgs;

    private int r;

    private int speed;

    private int dis;

    private int x;

    private int y;

    private int curAngle;

    public HLNetWait() {
    }

    public HLNetWait(int x, int y, int r) {
        Init(x, y, r);

    }

    public void Init(int x, int y, int r) {
        imgs = HLIOManager.LoadImages1("/netwait.pak");
        //
        this.r = r;
        this.x = x;
        this.y = y;
        dis = -30;
        speed = -30;
    }

    public void Render(HLGraphics g) {
        for (int i = imgs.length - 1; i >= 0; i--) {
            int rectX = x + (r * HLMathFP.cos((curAngle - dis * i) << BITS) >> BITS);
            int rectY = y - (r * HLMathFP.sin((curAngle - dis * i) << BITS) >> BITS);
            g.DrawImageAdjustable(new HLImage(imgs[i]), rectX, rectY, 0, 0, TRANS_NONE, HCENTER_VCENTER);
        }
        curAngle += speed;
    }
}
